<?php

namespace Admin\Controller;

use Think\Controller;

class IndexController extends Controller {

    public function index() {
        //  $this->show('<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} body{ background: #fff; font-family: "微软雅黑"; color: #333;font-size:24px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.8em; font-size: 36px } a,a:hover{color:blue;}</style><div style="padding: 24px 48px;"> <h1>:)</h1><p>欢迎使用 <b>ThinkPHP</b>！</p><br/>版本 V{$Think.version}</div><script type="text/javascript" src="http://ad.topthink.com/Public/static/client.js"></script><thinkad id="ad_55e75dfae343f5a1"></thinkad><script type="text/javascript" src="http://tajs.qq.com/stats?sId=9347272" charset="UTF-8"></script>','utf-8');

        $this->display();
    }

    function head() {

        $this->display();
    }

    //左边页面
    function left() {

        $firstMenuModel = new \Admin\Func\Func999010101(VL_MENULEVELFIRST, VL_ISMENUTRUE);
        $secondMenuModel = new \Admin\Func\Func999010101(VL_MENULEVELSCEOND, VL_ISMENUTRUE);
        $thirdMenuModel = new \Admin\Func\Func999010101(VL_MENULEVELTHIRD, VL_ISMENUTRUE);
        $firstMenuModel->execute();
        $secondMenuModel->execute();
        $thirdMenuModel->execute();
        $this->assign('firstMenuLst', $firstMenuModel->getRst());
        $this->assign('secondMenuLst', $secondMenuModel->getRst());
        $this->assign('thirdMenuLst', $thirdMenuModel->getRst());
        $this->display();
    }

    //右边页面
    function right() {

        \Think\Log::write('测试日志信息，这是警告级别，并且实时写入', 'WARN');
        $this->display();
    }

    // 首页
    public function test() {
        // $Form = M("Form");
        // 按照id排序显示前5条记录
        //$list = $Form->order('id desc')->limit(3)->select();
        // $this->list =   $list;
        $this->display();
    }

    // 检查标题是否可用
    public function checkTitle($title = '') {
        if (!empty($title)) {
            $this->success('标题可以使用!');
        } else {
            $this->error('标题必须');
        }
    }

    // 处理表单数据
    public function insert() {
        $Form = D("Form");
        if ($vo = $Form->create()) {
            if (false !== $Form->add()) {
                $vo['create_time'] = date('Y-m-d H:i:s', $vo['create_time']);
                $vo['content'] = nl2br($vo['content']);
                $this->ajaxReturn($vo, '表单数据保存成功！', 1);
            } else {
                $this->error('数据写入错误！');
            }
        } else {
            $this->error($Form->getError());
        }
    }

}
